package xyz.xiangyushui.util.dataBase;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;

import xyz.xiangyushui.dao.connectionFactory.JDBCConnectionFactory;

public class DBUtilTest {
	@SuppressWarnings("unchecked")
	public static void main(String[] args){
		DBUtil db=new DBUtil(new JDBCConnectionFactory());
		//db.executeUpdate("insert into user(name) values(?)", new Object[]{"hellen"});
		List<Object> list=db.excuteQuery("select * from salesDailyRecord where date>? and date<?", new Object[]{"2016-03-01","2016-03-32"});
		System.out.println(list.isEmpty());
		for(Object o:list){
			((Map<String,Object>)o).forEach((k,v)->{
				System.out.print(k+":"+v+" ");
			});
			System.out.println();
		}
		
		/*
		DBUtil db=new DBUtil(new JDBCConnectionFactory());
		List<Object> list=db.excuteQuery("select * from user where id=? and name=?", new Object[]{1,"hellen"});
		for(Object o:list){
			((Map<String,Object>)o).forEach((k,v)->{
				System.out.print(k+":"+v+" ");
			});
			System.out.println();
		}
		*/
		
		LocalDate l=LocalDate.now();
		System.out.println(l.plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
		
		//long 转date 再转string
		System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
		System.out.println(l.getMonth().getValue());
		
		
		//string 转date 再转long
		//1298822400000
		try {
			System.out.println(new SimpleDateFormat("yyyy-MM-dd").parse("2011-02-27").getTime());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
